MS-DOS Config.sys & Autoexec.bat


On Boot-up the computer reads two very important files CONFIG.SYS and AUTOEXEC.BAT both of which should be on the root directory of your boot drive. Usually the hard disk C:



 

NOTE:- Before we go any further copy C:\CONFIG.SYS to A:\CONFIG.TXT and C:\AUTOEXEC.BAT to A:\AUTOEXEC.TXT DO IT NOW!

From now on we will work on the .TXT copies on drive A: so log on to drive A:
Type the command:

EDIT A:\CONFIG.TXT {ENTER}

The above command and parameter will invoke the MS-DOS text editor window, with CONFIG.TXT loaded and ready for editing.
For example:

DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE RAM
DOS=HIGH,UMB
BUFFERS=10,0
FILES=40
LASTDRIVE=E
FCBS=4,0
STACKS=9,256
COUNTRY=044,,C:\DOS\COUNTRY.SYS
DEVICEHIGH /L:2,15792 =C:\DOS\DISPLAY.SYS CON=(EGA,850,2)
DEVICEHIGH /L:1,4560 =C:\WINDOWS\IFSHLP.SYS
SHELL=C:\COMMAND.COM C:\ /P /E:1024
Do not worry if your CONFIG.TXT does not have exactly the same commands, this is just a general example, but should cover most of the commands found.

Starting with the first line DEVICE = C:\DOS\HIMEM.SYS this allows MS-DOS to access some memory just above the 1Mb area called HIGH MEMORY.

Next DEVICE = C:\DOS\EMM386.EXE RAM this allows MS-DOS to access the some memory between the 640Kb and 1Mb called UPPER MEMORY BLOCKS and also to address and designate the type of memory available above 1Mb. In this example it gives access to EXPANDED memory and UMBs. If the NOEMS switch had been used instead of the RAM switch it would have given access to EXTENDED memory and UMBs.

DOS = HIGH,UMB is the command that moves most of the MS-DOS COMMAND.COM above the 1Mb area into HIGH MEMORY. This is in conjunction with HIMEM.SYS. It also maps out some of the 360Kb of UPPER MEMORY for use by TSR (Terminate and Stay Resident ) programs, for example DISPLAY.SYS if they are loaded into it.

The next five lines deal with BUFFERS - the number of disk segments that MS-DOS reads ahead.

                FILES - the number of files MS-DOS can open at one time.
                LASTDRIVE - the last drive letter that MS-DOS   
                recognises (default =E, max. =Z)
                FCBS - File Control BlockS contain details of a file
                STACKS - internal areas of memory that MS-DOS uses
                to keep track of things.
COUNTRY = 044,,C:\DOS\COUNTRY.SYS tells MS-DOS what country you are from, each major country except the USA has its own code number, usually tied in with the international telephone code for that country.

DEVICEHIGH /L:2,15792 = C:\DOS\DISPLAY.SYS CON(EGA,850,2) tells MS- DOS to load into an Upper Memory Block the display system TSR configured for EGA display. The /L: switch and numbers have been inserted by MEMMAKER a MS-DOS V6.x program that optimises the use of UMBs automatically. The DISPLAY command enables you to display international character sets on your monitor, in this example your system defaults to set 850 (English) and one other (the 2).
This TSR is virtually redundant with modern software so can usually be disabled without penalty. To disable this, or any, line in a text type file you use the REM command, followed by a space, to turn the line into a REMark. For example:

REM DEVICEHIGH = C:\DOS\DISPLAY.SYS CON(EGA,850,2)

would disable the line, on the next and subsequent Boot-ups.

DEVICEHIGH /L:1,4560 =C:\WINDOWS\IFSHLP.SYS is used by Windows for Workgroups and again has been loaded into upper memory.

SHELL=C:\COMMAND.COM C:\ /P /E:1024 the /E: sets an environment for COMMAND.COM of 1024 bytes (the default is 256 bytes). The /P makes the environment permanent i.e. you can't use the EXIT command as from a Windows DOS box.


Type the command:

EDIT A:\AUTOEXEC.TXT

The above command and parameter will invoke the MS-DOS text editor window, with AUTOEXEC.TXT loaded and ready for editing.

For example

@ECHO OFF
SET LMOUSE=C:\MOUSE
SET TEMP=C:\TEMP
PATH C:\;C:\DOS;C:\TC\BIN;C:\WINDOWS
LH KEYB UK,,C:\DOS\KEYBOARD.SYS
PROMPT DOS V6.22$p$g 
LH /L:0;2,45488 /S C:\DOS\SMARTDRV.EXE /X 512 128 
LH /L:0;2,25808 /S C:\MOUSE\MOUSE 
CLS
VER
WIN
Do not worry if your AUTOEXEC.TXT does not have exactly the same commands, this is just a general example, but should cover most of the commands found.

Starting with the first line @ECHO OFF the command ECHO is used to echo instructions to the screen, by default MS-DOS would echo to the screen all instructions in a BATch file (which is what this really is). So we issue the command to turn it OFF, but so that even this line is not displayed on the screen we prefix it with the @ symbol, which will suppress that line. So it would also be possible to miss this line out of the file and prefix all the other lines with the @ symbol.

SET LMOUSE = C:\MOUSE next we SET an environmental variable called LMOUSE to point to the directory where the Mouse Driver program is kept. This is so Windows knows where to look for the appropriate driver software to run your non- standard mouse or trackball. This setting is not required if you have a standard type mouse.

SET TEMP=C:\TEMP this sets the environmental variable TEMP, and points it to the TEMP directory on drive C: This allows Windows and MS-DOS to store TEMPary files in a known area of your Hard Disk. (i.e. the TEMP directory) If this is not set, TEMPary files may be stored anywhere and everywhere on your Disk (and they WILL be) making it very difficult to DELETE any that are taking up Disk space unnecessarily.

Next is the PATH command PATH C:\;C:\DOS\;C:\TC\BIN;C:WINDOWS this sets the list of directories that MS-DOS will look in to find a program if it is not in the current directory. In the above case it will look until it finds your program or command, first in the current directory, then at the ROOT directory of C: , then in the DOS directory, then in the BIN subdirectory of TC, and finally in the WINDOWS directory. If by this stage it has NOT found your program it gives up!!

LH KEYB UK,,C:\DOS\KEYBOARD.SYS Loads High (into Upper Memory Blocks) the program KEYB with the parameter UK. this tells MS-DOS that your keyboard is set out for the United Kingdom. The two comma's are there to insert a Page Frame Number between, empty as they are indicates that the default for the UK ( 850 or 437) will be used. Then the program KEYBOARD.SYS in the DOS directory will be loaded to enable MS-DOS to 'talk' to your keyboard.

PROMPT DOS V6.22 $p$g sets the DOS prompt you see on the screen with the words DOS V6.22 then the $p and $g add the directory backslash and the right pointed arrow to give DOS V6.22 C:\ >

LH /L:0;2,45488 /S C:\DOS\SMARTDRV.EXE /X 512 128 is the command to LOADHIGH the MS-DOS disk cache command SMARTDRIVE, the numbers after the /L: have been put there by MEMMAKER, which is a program in MS-DOS V6 or above and need not concern us at the moment. The SMARTDRIVE program uses a part of memory to CACHE (store) the next sectors on the Disk, as a file is read into memory. It can also be used to hold a file in memory before saving to disk, waiting until the CPU is not busy, and returning control of the computer to the user earlier than otherwise would be possible. The numbers at the end of the command line tell SMARTDRIVE to use a CACHE of 512 Bytes when MS-DOS is running, but only use a CACHE of 128 Bytes when Windows is in control.

LH /L:0,2,25808 /S C:\MOUSE\MOUSE Loads high the MOUSE driver, for use with MS-DOS programs. Note:- Windows has its own mouse driver, so if you NEVER run a DOS program that uses a mouse you do not need to load this driver. Again the numbers are not relevant at the moment.

CLS is the MS-DOS internal command to CLear the Screen, and is used to tidy up any output on the screen.

VER again is an internal MS-DOS command which displays the DOS version number on the screen.

WIN is the command to start Windows, without this your computer will leave you at the C:\> prompt.


MS-DOS Batch Commands

A batch file is a file containing a sequence of MS-DOS commands. If you find that you are typing one sequence of commands repeatedly, you can save a lot of time by placing the commands in a batch file. Then, by simply typing the name of the batch file, you can make MS-DOS carry out the command sequence, one command at a time, until the end of the batch file.

Creating and running a batch file

One way to create a batch file is to use the COPY command, another is to use EDIT, or any word processing program that lets you save files as ASCII text.
The examples below show you both methods of creating the same file. Suppose for example, you want to create a batch file that:- Using COPY
1.      At the MS-DOS prompt type:-
                COPY CON COPYFILE.BAT   {ENTER}

        This command tells MS-DOS to copy information you type in at the keyboard
        (the CONsole) into a new file called COPYFILE.BAT

2.      Type the following lines:-

                FORMAT A:       {ENTER}
                COPY *.*        {ENTER}
                DIR A:  {ENTER}

        After the last line, hold down the CTRL key and press the Z key.  Then press 
        {ENTER}  to save the file.  MS-DOS displays the message  ' 1 File (s) copied '
        to show that it has saved the file.
OR
1.      At the MS-DOS prompt type:-
                EDIT    COPYFILE.BAT    {ENTER}

2.      Type in the following lines:-

                FORMAT A:               {ENTER}
                COPY *.* A:             {ENTER}
                DIR A:          {ENTER}

3.      From the File drop down menu choose   Save 

4.      From the File drop down menu choose Exit  to close the EDIT program.

To run the file Type:-

COPYFILE {ENTER}

NOTE:- there is no need to type the extension for MS-DOS to run a file with a BAT, EXE or COM extension.

Points to remember about Batch files

You can stop a running batch file by holding down the CRTL key and pressing the C key. MS-DOS displays this message,

Terminate batch job (Y/N)?

If you type Y, the rest of the commands are ignored and the MS-DOS prompt appears.


A List of extra Batch file commands

This is the end of the lessons on MS-DOS.

Part 5 Questions
  1. What files does MS-DOS read on Boot up?
  2. What command in the CONFIG.SYS allows MS-DOS to access the High Memory area?
  3. What is the country code for . . . a) The UK ? b) The USA ?
  4. What commands do you need, to put programs into Upper Memory, in a) CONFIG.SYS ? b) AUTOEXEC.BAT ?
  5. How do you point MS-DOS to a directory you have designated for it to store it's temporary files?
  6. What happens if the program you want to run is NOT on the list of directories given in the PATH statement (in AUTOEXEC.BAT) ? And give TWO ways how you could make sure that MS-DOS found and ran the program.
  7. What does SMARTDRIVE do?
  8. Your Mouse works in Windows, but NOT when using MS-DOS programs, give one possible reason.
  9. What is a batch file?
  10. What would you expect the following batch file to do? Comment on each line.

  11. TIP:- Use the HELP command if you are not sure what a particular command does.
                @ECHO OFF
                REM This is DISPLAY.BAT
                CLS
                TYPE A:\AUTOEXEC.TXT
                PAUSE
                CLS
                COPY A:\AUTOEXEC.TXT A:\AUTOEXEC.OLD
                DIR A:
                PAUSE
                CLS
                VOL
                VER
If you create this as a batch file, ensure that there is a diskette in drive A: with a file called AUTOEXEC.TXT on it.
You created such a diskette earlier in the course.

Return to DOS menu

E-Mail your answers to:-

dos5@butterwick0.freeserve.co.uk